package com.giscloud.amp.controller.map;

import com.giscloud.amp.controller.BaseController;
import com.giscloud.amp.entity.PubDictValue;
import com.giscloud.amp.entity.dto.DictionaryDTO;
import com.giscloud.amp.entity.dto.DictionaryValueDTO;
import com.giscloud.amp.service.sys.DictionaryService;
import com.giscloud.commons.model.Result;
import com.giscloud.datasource.page.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author gxd
 * @data 2018/12/4 10:16
 */
@SuppressWarnings("SpringJavaAutowiringInspection") //加这个注解让IDE 不报: Could not autowire
@RestController
public class AmpDictionaryController extends BaseController {

    private static final Logger log = LoggerFactory.getLogger(AmpDictionaryController.class);

    @Autowired
    private DictionaryService dictionaryClient;

    /**
     * 字典列表
     * @param dictionaryDTO
     * @return
     */
    @RequestMapping(value="/amp/dictionary/getList",method = RequestMethod.POST)
    public PageInfo getList(@RequestBody DictionaryDTO dictionaryDTO) {
        return dictionaryClient.getList(dictionaryDTO);
    }


    /**
     * 字典新增
     * @param dictionaryDTO
     * @return
     */
    @RequestMapping(value="/amp/dictionary/add",method = RequestMethod.POST)
    public Result add(@RequestBody DictionaryDTO dictionaryDTO){
        return dictionaryClient.add(dictionaryDTO);
    }

    /**
     * 字典编辑
     * @param dictionaryDTO
     * @return
     */
    @RequestMapping(value="/amp/dictionary/edit",method = RequestMethod.POST)
    public Result edit(@RequestBody DictionaryDTO dictionaryDTO){
        return dictionaryClient.edit(dictionaryDTO);
    }

    /**
     * 字典删除
     * @return
     */
    @RequestMapping(value="/amp/dictionary/delete",method = RequestMethod.POST)
     public Result delete(@RequestBody DictionaryDTO dictionaryDTO){
        return dictionaryClient.delete(dictionaryDTO.getDictId());
     }



    /**
     * 字典值列表
     * @param dictionaryValueDTO
     * @return
     */
    @RequestMapping(value="/amp/dictionary/getListValue",method = RequestMethod.POST)
    public PageInfo getListValue(@RequestBody DictionaryValueDTO dictionaryValueDTO) {
        return dictionaryClient.getListValue(dictionaryValueDTO);
    }

    /**
     * 字典值新增
     * @param dictionaryValueDTO
     * @return
     */
    @RequestMapping(value="/amp/dictionary/valueAdd",method = RequestMethod.POST)
    public Result valueAdd(@RequestBody DictionaryValueDTO dictionaryValueDTO){
        return dictionaryClient.valueAdd(dictionaryValueDTO);
    }

    /**
     * 字典值删除
     * @param dictionaryValueDTO
     * @return
     */
    @RequestMapping(value="/amp/dictionary/valueDelete",method = RequestMethod.POST)
    public Result valueDelete(@RequestBody DictionaryValueDTO dictionaryValueDTO){
        return dictionaryClient.valueDelete(dictionaryValueDTO.getDictValueId());
    }

    /**
     * 字典值编辑
     * @param dictionaryValueDTO
     * @return
     */
    @RequestMapping(value="/amp/dictionary/valueEdit",method = RequestMethod.POST)
    public Result valueEdit(@RequestBody DictionaryValueDTO dictionaryValueDTO){
        return dictionaryClient.valueEdit(dictionaryValueDTO);
    }

    /**
     * 字典列表
     *
     *  @return
     */
    @RequestMapping(value="/amp/dictionary/getDictMap",method = RequestMethod.POST)
    public List<Map<String,Object>> getDictMap(){
        List<Map<String,Object>> map = dictionaryClient.getDictMap();
        return map;
    }


    /**
     * 根据条件字典列表
     *
     *  @return
     */
    @RequestMapping(value="/amp/dictionary/getDictList/{dictKey}",method = RequestMethod.POST)
    public List<Map<String,Object>> getDictList(@PathVariable("dictKey") String dictKey){
        return dictionaryClient.getDictList(dictKey);
    }

    /**
     * 列表
     */
    @RequestMapping("/limp/pubdictvalue/list")
    public Result pubdictvalue(@RequestBody DictionaryValueDTO pubDictValueDTO){
        List<Map<String,Object>> list = dictionaryClient.pubdictValueList(pubDictValueDTO);
        return Result.success(list);
    }

    /**
     * 列表
     */
    @RequestMapping("/amp/pubdictvalue/list")
    public Result pubdictvalue1(@RequestBody DictionaryValueDTO pubDictValueDTO){
        List<Map<String,Object>> list = dictionaryClient.pubdictValueList(pubDictValueDTO);
        return Result.success(list);
    }
}
